/*    */ package com.zimbra.cs.redolog;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.cs.redolog.op.CommitTxn;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CommitId
/*    */ {
/*    */   private long mRedoSeq;
/*    */   private long mTxnTstamp;
/*    */   private TransactionId mTxnId;
/*    */   
/*    */   private CommitId(long seq, long txnTstamp, TransactionId txnId)
/*    */   {
/* 40 */     this.mRedoSeq = seq;
/* 41 */     this.mTxnTstamp = txnTstamp;
/* 42 */     this.mTxnId = txnId;
/*    */   }
/*    */   
/*    */   public CommitId(long seq, CommitTxn txn) {
/* 46 */     this(seq, txn.getTimestamp(), txn.getTransactionId());
/*    */   }
/*    */   
/*    */   public boolean matches(CommitTxn txn) {
/* 50 */     return (this.mTxnId.equals(txn.getTransactionId())) && (this.mTxnTstamp == txn.getTimestamp());
/*    */   }
/*    */   
/*    */   public long getRedoSeq() {
/* 54 */     return this.mRedoSeq;
/*    */   }
/*    */   
/*    */   public String encodeToString() {
/* 58 */     int time = this.mTxnId.getTime();
/* 59 */     int counter = this.mTxnId.getCounter();
/* 60 */     StringBuilder sb = new StringBuilder();
/* 61 */     sb.append(this.mRedoSeq).append('-');
/* 62 */     sb.append(this.mTxnTstamp).append('-');
/* 63 */     sb.append(this.mTxnId.encodeToString());
/* 64 */     return sb.toString();
/*    */   }
/*    */   
/*    */   public static CommitId decodeFromString(String str) throws ServiceException
/*    */   {
/* 69 */     Throwable cause = null;
/* 70 */     if (str != null) {
/* 71 */       String[] fields = str.split("-", 3);
/* 72 */       if ((fields != null) && (fields.length == 3)) {
/*    */         try {
/* 74 */           long seq = Long.parseLong(fields[0]);
/* 75 */           long txnTstamp = Long.parseLong(fields[1]);
/* 76 */           TransactionId txnId = TransactionId.decodeFromString(fields[2]);
/* 77 */           return new CommitId(seq, txnTstamp, txnId);
/*    */         } catch (NumberFormatException e) {
/* 79 */           cause = e;
/*    */         } catch (ServiceException e) {
/* 81 */           cause = e;
/*    */         }
/*    */       }
/*    */     }
/* 85 */     throw ServiceException.PARSE_ERROR("Invalid CommitId " + str, cause);
/*    */   }
/*    */   
/*    */   public String toString() {
/* 89 */     return encodeToString();
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/redolog/CommitId.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */